package connection;

import java.sql.SQLException;

public class ConnecPool {


	private JDCConnectionPool pool;
	private String url;
	private static volatile ConnecPool INSTANCE;
	
	private ConnecPool(){
		creerConnection();
	}
	public void creerConnection(){
		String driver = "com.mysql.jdbc.Driver";
		//String driver = "net.sourceforge.jtds.jdbc.Driver";
		url = "jdbc:mysql://gti710.logti.etsmtl.ca/gti710_2009_3_04";
		String user="dbadmin04";
		String pass="YhtbHhE9";
		try {
				Class.forName(driver);
				pool = new JDCConnectionPool(url, user, pass);
		} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		} 
				
		
	}
	public JDCConnection getConnection(){
		try {
			return pool.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
	public static ConnecPool getInstance() {
	     if (INSTANCE == null)
	       synchronized(ConnecPool.class) {
	         if (INSTANCE == null)
	           INSTANCE = new ConnecPool();
	       }
	     return INSTANCE;
	}

}
